package cn.yj.core.task.delay.task;

import cn.yj.core.task.delay.BaseDelayTaskEntity;
import cn.yj.core.task.delay.CallBackFinish;

import java.util.concurrent.TimeUnit;

/**
 * 其它任务
 *
 * @author 永健
 * @since 2021-05-12 15:11
 */
public class TaskDelayEntity extends BaseDelayTaskEntity {

    private CallBackFinish<TaskDelayEntity> callback;

    public CallBackFinish<TaskDelayEntity> getCallback() {
        return callback;
    }

    public TaskDelayEntity setCallback(CallBackFinish<TaskDelayEntity> callback) {
        this.callback = callback;
        return this;
    }

    public TaskDelayEntity() {
        this(null, 0, null, null);
    }

    public TaskDelayEntity(Runnable task, long delay, TimeUnit timeUnit, String uniq) {
        super(task, delay, timeUnit, uniq);
    }


    public TaskDelayEntity setTask(Runnable task) {
        this.task = task;
        return this;
    }

    public TaskDelayEntity setDelay(long delay) {
        this.delay = delay;
        return this;
    }

    public TaskDelayEntity setTimeUnit(TimeUnit timeUnit) {
        this.timeUnit = timeUnit;
        return this;
    }

    public TaskDelayEntity setUnique(String unique) {
        this.unique = unique;
        return this;
    }

    @Override
    public Runnable getTask() {
        return task;
    }

    @Override
    public long getDelay() {
        return delay;
    }

    @Override
    public TimeUnit getTimeUnit() {
        return timeUnit;
    }

    @Override
    public String getUnique() {
        return unique;
    }
}
